<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCouponsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('coupons', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('enterprise_id')->default(0)->comment('企业id');
            $table->bigInteger('merchant_id')->default(0)->comment('商家id');
            $table->string('name')->nullable()->comment('优惠券名称');
            $table->decimal('money')->default(0)->comment('优惠券金额');
            $table->timestamp('start_time')->nullable()->comment('开始时间');
            $table->timestamp('end_time')->nullable()->comment('结束时间');
            $table->string('type')->nullable()->comment('优惠券类型 direct 直接优惠/satisfy 满金额优惠');
            $table->decimal('satisfy_money')->default(0)->comment('满足优惠需要的金额');
            $table->integer('effective_time')->default(0)->comment('有效时间（天）');
            $table->integer('num')->default(0)->comment('发放数量');
            $table->string('remark')->nullable()->comment('备注');
            $table->bigInteger('img_id')->default(0)->comment('图片');
            $table->integer('status')->default(0)->comment('状态 0：停用 1：启用');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('coupons');
    }
}
